package org.se.scut.hibernate.dao.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "tb_picture")
public class Picture extends Model {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
	
	@Column(name = "overView")
	private String overView;
	
	@Column(name = "filePath")
	private String filePath;
	
	@Column(name = "file_length")
	private int fileLength;
	
	@Column(name = "numOfCollected")
	private int numOfCollected;
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "picture_id")
	@OrderBy(value = "createTime desc")
	private Set<Comment> comments;

	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;
	
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "userinfo_id")
	private UserInfo creator;
	
	@ManyToOne(cascade = CascadeType.PERSIST)
	@JoinColumn(name = "pictrue_type_id")
	private PictureType pictureType;
	
	public Integer getId() {		
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getOverView() {
		return overView;
	}

	public void setOverView(String overView) {
		this.overView = overView;
	}

	public int getNumOfLove() {
		return numOfCollected;
	}

	public void setNumOfLove(int numOfLove) {
		this.numOfCollected = numOfLove;
	}

	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

	public int getContent_length() {
		return fileLength;
	}

	public void setContent_length(int content_length) {
		this.fileLength = content_length;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public UserInfo getCreator() {
		return creator;
	}

	public void setCreator(UserInfo creator) {
		this.creator = creator;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public PictureType getPictureType() {
		return pictureType;
	}

	public void setPictureType(PictureType pictureType) {
		this.pictureType = pictureType;
	}

	
}
